﻿namespace FFF.Test.Entity.Demo.Function
{
    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.IO;
    using System.Text;
    using Microsoft.Extensions.Configuration;
    using FFF.Test.Util.Configuration;
    using Ydm.Helper;
    using FFF.Test.Util.Consts;

    /// <summary>
    /// fn_Demo_splitarr函数
    /// </summary>
    public class FnDemoSplitarr
    {
        /// <summary>
        /// @arr
        /// </summary>
        public string @Arr { get; set; }

        /// <summary>
        /// @split
        /// </summary>
        public string @Split { get; set; }

        /// <summary>
        /// 获取List集合
        /// </summary>
        /// <returns>list集合</returns>
        public List<FnDemoSplitarrTableInfo> QueryList()
        {
            var conStr = AppConfigConsts.ConStr;
            string sql = this.GetSql();
            return DBHelper.QueryList<FnDemoSplitarrTableInfo>(conStr, sql, null);
        }

        /// <summary>
        /// 获取sql
        /// </summary>
        /// <returns>获取sqlstr</returns>
        private string GetSql()
        {
            string sql = "SELECT * FROM dbo.fn_Demo_splitarr( ";
            sql += $"'{this.@Arr}',";
            sql += $"'{this.@Split}',";
            sql = sql.Substring(0, sql.Length - 1);
            sql += ");";
            return sql;
        }
    }

    /// <summary>
    /// 这个函数的返回值
    /// </summary>
    public class FnDemoSplitarrTableInfo
    {
        /// <summary>
        /// pos
        /// </summary>
        public int Pos { get; set; }

        /// <summary>
        /// value
        /// </summary>
        public string Value { get; set; }
    }
}
